
import Resource from '@/api/examine';
const examineResource = new Resource('examine');

const state={
  examine: localStorage.getItem('examineAll')?JSON.parse(localStorage.getItem('examineAll')):'',
  routeUrl:''
};

const mutations={
  SET_EXAMINE:(state,data)=>{
    state.examine=data;
  },
  SET_ROUTE_URL:(state,data)=>{
    state.routeUrl=data;
  }
};

const actions={
  async setExamine({ commit }){

    const { data } = await examineResource.getExamineAll({});
    const ob = {};
    data.map(item=>{
      ob[item['types']]=item;
    })
    localStorage.setItem('examineAll',JSON.stringify(ob))
    commit('SET_EXAMINE',ob);
  },
  setRouteUrl({commit},url){
    commit('SET_ROUTE_URL',url);
  }
}

export default {
  namespaced: true,
  state,
  mutations,
  actions,
};
